import QtQuick 2.1
import Qt.labs.folderlistmodel 2.1
import Qt.labs.controls 1.0
import QtQuick.Layouts 1.1
Navigator {
    id: fileBrowser

    property alias  folder : folderModel.folder

    property Item item: null


    ListView {
        id: listView
        anchors.fill: parent

        FolderListModel {
            id: folderModel
            nameFilters: ["*.png", "*.jpg"]
        }

        model: folderModel
        delegate: ItemDelegate {
            height: 120
            width:  listView.width

            RowLayout {
                anchors.fill: parent
                Image {
                    source: fileURL
                    Layout.preferredHeight: 96
                    Layout.preferredWidth: 96
                    asynchronous: true
                    Layout.alignment: Qt.AlignVCenter
                }
                ColumnLayout {
                    Layout.fillWidth: true
                    Label {
                        Layout.alignment: Qt.AlignVCenter
                        text: fileName
                    }

                    ToolButton {
                        text: "选择"
                        onClicked: {fileBrowser.item.fileUrl = fileURL;contentArea.pop(); }
                    }
                }
            }
            Rectangle {
                height: 1
                width: parent.width
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 1
                visible: index != (listView.count - 1)
            }
        }
    }




}
